package main

import (
	"os"
	"fmt"
)

func main() {
	f:=createFile("defer.txt")

	defer closeFile(f)

	writeFile(f)
}

func createFile(p string) *os.File{
	fmt.Println("creating")
	f,err:=os.Create(p)
	if err!=nil{
		panic(err)
	}
	return f
}


func writeFile(f *os.File){
	fmt.Println("writing")
	fmt.Fprintln(f,"我是黄柳淞")
}

func closeFile(f *os.File){
	fmt.Println("closing")
	f.Close()
}
